﻿using System.Reflection;
using System.Web.Mvc;
using System.Web.Routing;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework.Config;
using MyMovieCollection.DATA.Models;

namespace MyMovieCollection
{
    public class GlobalApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
      
            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Product", action = "Index", id = "" }  // Parameter defaults
            );
            routes.MapRoute("ShowBigImage",
                "{controller}/{action}/{fileName}/{MovieName}",
                new { controller = "Product", action = "", fileName = "", MovieName = "" }
            );
           


        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
            XmlConfigurationSource source = new XmlConfigurationSource(Server.MapPath("~/ActiveRecordSettings.xml"));
            ActiveRecordStarter.Initialize(source, typeof(MovieType), typeof(Movie));
            //ActiveRecordStarter.Initialize(Assembly.Load("BusinessLayer"), source);
            //ActiveRecordStarter.CreateSchema();
        }
    }
}